import type { EnterpriseBase, PaginationType } from "@/types"
import { reactive, ref } from "vue"

export default function usePageState() {
  const dialogVisible = ref<boolean>(false)
  const loading = ref<boolean>(false)

  const searchForm = reactive({
    name: '',
    status: '',
    industry: ''
  })

  const pagination = reactive<PaginationType>({
    current: 1,
    size: 10,
    total: 0
  })

  const tableData = ref<EnterpriseBase[]>([
    {
      id: 1,
      name: '阿里巴巴集团',
      shortName: '阿里',
      industry: '互联网',
      size: '500+',
      logoUrl: '',
      contactName: '张三',
      contactEmail: 'zhangsan@alibaba.com',
      contactPhone: '13800138000',
      location: '杭州',
      status: 'active',
      createdAt: '2024-01-15T10:30:00'
    },
    {
      id: 2,
      name: '腾讯科技',
      shortName: '腾讯',
      industry: '互联网',
      size: '500+',
      logoUrl: '',
      contactName: '李四',
      contactEmail: 'lisi@tencent.com',
      contactPhone: '13800138001',
      location: '深圳',
      status: 'active',
      createdAt: '2024-01-16T14:20:00'
    }
  ])

  const formatDate = (dateString: string): string => {
    return new Date(dateString).toLocaleString('zh-CN')
  }
  return {
    dialogVisible,
    loading,
    searchForm,
    pagination,
    tableData,
    formatDate
  }
}
